<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>

<script runat="server">

    private void Page_Load(object sender, EventArgs e)
    {
        string xmlPath = Request.PhysicalApplicationPath + @"\Application_Data\Books.xml";
        XmlDocument booksDoc = new XmlDocument();
        XmlDocument empDoc = new XmlDocument();
        Response.ContentType = "text/xml";
        try
        {
            //Load the XML from the file
            booksDoc.PreserveWhitespace = true;
            booksDoc.Load(xmlPath);
            //Write the XML onto the browser
            Response.Write(booksDoc.InnerXml);
            //Load the XML from a String
            empDoc.LoadXml("<employees>" +
                           "<employee id='1'>" +
                           "<name><firstName>Nancy</firstName>" +
                           "<lastName>Davolio</lastName>" +
                           "</name><city>Seattle</city>" +
                           "<state>WA</state><zipCode>98122</zipCode>" +
                           "</employee></employees>");
            //Save the XML data onto a file                    
            empDoc.Save(@"C:\Data\Employees.xml");
        }
        catch (XmlException xmlEx)
        {
            Response.Write("XmlException: " + xmlEx.Message);
        }
        catch (Exception ex)
        {
            Response.Write("Exception: " + ex.Message);
        }
    }

</script>